package com.example.service.webhook.business.jingdong.dto;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.io.*;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * @author liyang
 * @email liyang@51dojo.com
 * @create 2017-10-23 下午6:04
 * @description 京东金条
 **/
@JsonIgnoreProperties(ignoreUnknown = true)
public class JdJinTiaoBill {
    @JsonProperty("mapping_id")
    private String mappingId;

    @JsonProperty("loan_id")
    private String loanId;

    @JsonProperty("product_id")
    private String productId;

    @JsonProperty("product_name")
    private String productName;

    @JsonProperty("status_code")
    private String statusCode;

    @JsonProperty("original_amount")
    private BigDecimal originalAmount;

    @JsonProperty("retail_date")
    private int retailDate;

    @JsonProperty("retail_time")
    private int retailTime;

    @JsonProperty("original_terms")
    private int originalTerms;

    @JsonProperty("current_term")
    private int currentTerm;

    @JsonProperty("outstanding_amount")
    private BigDecimal outstandingAmount;

    @JsonProperty("outstanding_terms")
    private int outstandingTerms;

    @JsonProperty("jd_order_no")
    private String jdOrderNo;

    @JsonProperty("jd_pay_order_no")
    private String jdPayOrderNo;

    @JsonProperty("cashier_order_no")
    private String cashierOrderNo;

    @JsonProperty("current_due_date")
    private Date currentDueDate;

    @JsonProperty("total_payment_amount")
    private BigDecimal totalPaymentAmount;

    @JsonProperty("pay_amount")
    private BigDecimal payAmount;

    @JsonProperty("pay_plan_num")
    private int payPlanNum;

    @JsonProperty("over_plan_num")
    private int overPlanNum;

    @JsonProperty("over_amount")
    private BigDecimal overAmount;

    @JsonProperty("refund_amount")
    private BigDecimal refundAmount;

    @JsonProperty("loan_amount_discount")
    private BigDecimal loanAmountDiscount;

    @JsonProperty("over_due_days")
    private int overDueDays;

    @JsonProperty("max_over_due_days")
    private int maxOverDueDays;

    @JsonProperty("finish_pay_date")
    private Date finishPayDate;

    private List<JdJinTiaoBillPlan> plans;

    public String getMappingId() {
        return mappingId;
    }

    public void setMappingId(String mappingId) {
        this.mappingId = mappingId;
    }

    public String getLoanId() {
        return loanId;
    }

    public void setLoanId(String loanId) {
        this.loanId = loanId;
    }

    public String getProductId() {
        return productId;
    }

    public void setProductId(String productId) {
        this.productId = productId;
    }

    public String getProductName() {
        return productName;
    }

    public void setProductName(String productName) {
        this.productName = productName;
    }

    public String getStatusCode() {
        return statusCode;
    }

    public void setStatusCode(String statusCode) {
        this.statusCode = statusCode;
    }

    public BigDecimal getOriginalAmount() {
        return originalAmount;
    }

    public void setOriginalAmount(BigDecimal originalAmount) {
        this.originalAmount = originalAmount;
    }

    public int getRetailDate() {
        return retailDate;
    }

    public void setRetailDate(int retailDate) {
        this.retailDate = retailDate;
    }

    public int getRetailTime() {
        return retailTime;
    }

    public void setRetailTime(int retailTime) {
        this.retailTime = retailTime;
    }

    public int getOriginalTerms() {
        return originalTerms;
    }

    public void setOriginalTerms(int originalTerms) {
        this.originalTerms = originalTerms;
    }

    public int getCurrentTerm() {
        return currentTerm;
    }

    public void setCurrentTerm(int currentTerm) {
        this.currentTerm = currentTerm;
    }

    public BigDecimal getOutstandingAmount() {
        return outstandingAmount;
    }

    public void setOutstandingAmount(BigDecimal outstandingAmount) {
        this.outstandingAmount = outstandingAmount;
    }

    public int getOutstandingTerms() {
        return outstandingTerms;
    }

    public void setOutstandingTerms(int outstandingTerms) {
        this.outstandingTerms = outstandingTerms;
    }

    public String getJdOrderNo() {
        return jdOrderNo;
    }

    public void setJdOrderNo(String jdOrderNo) {
        this.jdOrderNo = jdOrderNo;
    }

    public String getJdPayOrderNo() {
        return jdPayOrderNo;
    }

    public void setJdPayOrderNo(String jdPayOrderNo) {
        this.jdPayOrderNo = jdPayOrderNo;
    }

    public String getCashierOrderNo() {
        return cashierOrderNo;
    }

    public void setCashierOrderNo(String cashierOrderNo) {
        this.cashierOrderNo = cashierOrderNo;
    }

    public Date getCurrentDueDate() {
        return currentDueDate;
    }

    public void setCurrentDueDate(Date currentDueDate) {
        this.currentDueDate = currentDueDate;
    }

    public BigDecimal getTotalPaymentAmount() {
        return totalPaymentAmount;
    }

    public void setTotalPaymentAmount(BigDecimal totalPaymentAmount) {
        this.totalPaymentAmount = totalPaymentAmount;
    }

    public BigDecimal getPayAmount() {
        return payAmount;
    }

    public void setPayAmount(BigDecimal payAmount) {
        this.payAmount = payAmount;
    }

    public int getPayPlanNum() {
        return payPlanNum;
    }

    public void setPayPlanNum(int payPlanNum) {
        this.payPlanNum = payPlanNum;
    }

    public int getOverPlanNum() {
        return overPlanNum;
    }

    public void setOverPlanNum(int overPlanNum) {
        this.overPlanNum = overPlanNum;
    }

    public BigDecimal getOverAmount() {
        return overAmount;
    }

    public void setOverAmount(BigDecimal overAmount) {
        this.overAmount = overAmount;
    }

    public BigDecimal getRefundAmount() {
        return refundAmount;
    }

    public void setRefundAmount(BigDecimal refundAmount) {
        this.refundAmount = refundAmount;
    }

    public BigDecimal getLoanAmountDiscount() {
        return loanAmountDiscount;
    }

    public void setLoanAmountDiscount(BigDecimal loanAmountDiscount) {
        this.loanAmountDiscount = loanAmountDiscount;
    }

    public int getOverDueDays() {
        return overDueDays;
    }

    public void setOverDueDays(int overDueDays) {
        this.overDueDays = overDueDays;
    }

    public int getMaxOverDueDays() {
        return maxOverDueDays;
    }

    public void setMaxOverDueDays(int maxOverDueDays) {
        this.maxOverDueDays = maxOverDueDays;
    }

    public Date getFinishPayDate() {
        return finishPayDate;
    }

    public void setFinishPayDate(Date finishPayDate) {
        this.finishPayDate = finishPayDate;
    }

    public List<JdJinTiaoBillPlan> getPlans() {
        return plans;
    }

    public void setPlans(List<JdJinTiaoBillPlan> plans) {
        this.plans = plans;
    }

    public static void main(String[] args) throws IOException {
        FileReader fr = new FileReader(new File("/Users/liyang/Desktop/dealChar.txt"));
        BufferedReader bf = new BufferedReader(fr);

        String line = null;
        StringBuilder jsonProp;

        StringBuilder sbType;

        StringBuilder sbProp;
        StringBuilder sbJson = new StringBuilder("@JsonProperty()");

        while ((line = bf.readLine()) != null) {
            if (line.equals("") || line.length() == 0){
                continue;
            }
            String[] strs = line.trim().split(":");
            jsonProp = new StringBuilder(strs[0]);

            sbType = new StringBuilder(strs[1]);
            //System.out.println(sbType.toString());

            sbJson.insert(sbJson.indexOf("(") + 1, jsonProp.toString());

            System.out.println(sbJson.toString());

            sbProp = new StringBuilder(sbJson);
            sbProp = jsonProp.deleteCharAt(0);//删除引号
            sbJson = sbProp.deleteCharAt(sbProp.length() - 1);

            while (sbProp.indexOf("_") >= 0) {
                sbProp = sbProp.replace(sbProp.indexOf("_") + 1, sbProp.indexOf("_") + 2, sbProp.substring(sbProp.indexOf("_") + 1, sbProp.indexOf("_") + 2).toUpperCase());

                sbProp.replace(sbProp.indexOf("_"), sbProp.indexOf("_") + 1, "");
            }
            if (sbType.toString().contains("string")) {
                System.out.println("private String " + sbProp.toString() + ";\n");
            } else if (sbType.toString().contains("date")) {
                System.out.println("private Date " + sbProp.toString() + ";\n");
            } else if (sbType.toString().contains("int")) {
                System.out.println("private int " + sbProp.toString() + ";\n");
            } else if (sbType.toString().contains("decimal")) {
                System.out.println("private BigDecimal " + sbProp.toString() + ";\n");
            } else {
                System.out.println("private " + sbProp.toString() + ";\n");
            }

            sbJson = new StringBuilder("@JsonProperty()");

        }


    }


}
